package cn.zane.principle.openAndClosePrinciple.design.impl;

import cn.zane.principle.openAndClosePrinciple.design.ICalculationArea;

/**
 * @Author: zane
 * @Date: 2024/12/13
 * @Description: 面积计算实现
 */
public class CalculationArea implements ICalculationArea {

    private final static double PI = 3.14D;

    @Override
    public double rectangle(double length, double width) {
        return length * width;
    }

    @Override
    public double rectangle(double x, double y, double z) {
        double p = (x + y + z) / 2;
        return Math.sqrt(p * (p - x) * (p - y) * (p - z));
    }

    @Override
    public double circular(double radius) {
        return PI * radius * radius;
    }
}
